<template>
  <div class="mine">
    <div class="header">
      <div class="avator">
        <img src="../images/bilibili.png" alt="">
      </div>
      <div class="user">
        欢迎使用
        <div class="vip">
          正式会员
        </div>
      </div>
    </div>
    <div class="buttom">
      <van-button round block type="danger" @click="onSubmit" native-type="submit">退出登录</van-button>
    </div>
  </div>
</template>

<script setup>
import { onMounted } from "@vue/runtime-core";
import { getLocal } from '../common/js/utils'
import { useRouter } from "vue-router";

const router = useRouter()

const onSubmit = () => {
  localStorage.removeItem('token')
  window.location.href = '/home'
}

onMounted(() => {
 let token = getLocal('token')
//  console.log(getLocal('token'));
 if(!token) {
   router.push('/login')
 }
})
</script>

<style scoped>
.mine{
  padding: 30px 10px;
}
.header{
  display: flex;
  margin-top: 60px;
  margin-left: 30px;
}
.avator img{
  width: 50px;
  height: 50px;
  border-radius: 40%;
}
.user{
  margin-left: 20px;
}
.vip{
  width: 50px;
  height: 15px;
  font-size: 10px;
  border: 1px solid rgb(245, 127, 147);
  border-radius: 2px;
  margin-top: 6px;
  color: rgb(245, 127, 147);
}
.buttom{
  margin-top: 100px;
}
</style>